package thread.threadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

/**
 * 线程池
 *
 * @author lwmzzz
 * @version 1.0
 * @date 2021/5/18 23:50
 */
public class Test01 {
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(5);

        for (int i = 0; i < 18; i++) {
            executorService.execute(() -> {
                System.out.println(Thread.currentThread().getId() + " 编号的线程正在执行任务，开始时间： " + System.currentTimeMillis());
                try {
                    TimeUnit.SECONDS.sleep(2);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            });
        }
    }
}
